package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-07-27
 * Time: 11:38
 */
public class test8 {


    public static boolean flg = false;

    public static void main(String[] args) {

        Thread t = new Thread(()->{
            while(!flg){
                System.out.println("我是Thread!!!");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("终止Thread");
            }
        });
        t.start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        flg = true;
        System.out.println("我是main");
    }


}
